package com.sali;

import com.sali.config.NettyConfig;
import com.sali.netty.NettyClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;

@SpringBootApplication
@EnableScheduling
public class NettyClientApplication {

    @Resource(name = "commonExecutor")
    private ExecutorService executorService;

    @Resource(name = "myTaskExecutor")
    private ScheduledExecutorService scheduledExecutorService;

    @Resource
    private NettyClient nettyClient;



    public static void main(String[] args) {
        SpringApplication.run(NettyClientApplication.class, args);
    }

    @PostConstruct
    public void init() {
        executorService.execute(() -> nettyClient.start(scheduledExecutorService));
    }



}
